package com.xiaohao.communication.daoImpl;

import com.xiaohao.communication.bean.WorkClassifications;
import com.xiaohao.communication.dao.WorkClassificationsDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class WorkClassificationDaoImpl implements WorkClassificationsDao {


    @Autowired
    MongoTemplate mongoTemplate;


    @Override
    public WorkClassifications findByType(String type) {
        return mongoTemplate.findOne(new Query(Criteria.where("type").is(type))
                , WorkClassifications.class, "workClassifications");
    }


    @Override
    public List<WorkClassifications> findAll() {
        return mongoTemplate.find(new Query(), WorkClassifications.class, "workClassifications");
    }


}
